package com.zsy.flink.sink;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Description:
 * @ClassName: SinkApp
 * @Author: Zhou ShiYang
 * @Date: 2021/8/26 15:14
 */
public class SinkApp {

    public static void main(String[] args) throws Exception {
        // 创建上下文
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> source = env.readTextFile("data/wc.data");

        System.out.println("source并行度：" + source.getParallelism());

        // 强制设定并行度为1
        source.print().setParallelism(1);

        // 输出为红色字体
        source.printToErr().setParallelism(1);

        // 加一个前缀：test> xxx     1:哪个内核   test:1> xxx
        source.print("test").setParallelism(2);

        env.execute("SourceApp");
    }
}
